package com.ruoyi.buss.report.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.buss.utils.DateUtilss;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.buss.report.mapper.ReportDkjgDblxLsbMapper;
import com.ruoyi.buss.report.domain.ReportDkjgDblxLsb;
import com.ruoyi.buss.report.service.IReportDkjgDblxLsbService;

/**
 * 贷款结构趋势-担保类型结构图4.3.1.1.1-3Service业务层处理
 * 
 * @author sxy
 * @date 2021-07-16
 */
@Service
public class ReportDkjgDblxLsbServiceImpl implements IReportDkjgDblxLsbService 
{
    @Autowired
    private ReportDkjgDblxLsbMapper reportDkjgDblxLsbMapper;

    /**
     * 查询贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * 
     * @param sjrq 贷款结构趋势-担保类型结构图4.3.1.1.1-3ID
     * @return 贷款结构趋势-担保类型结构图4.3.1.1.1-3
     */
    @Override
    public ReportDkjgDblxLsb selectReportDkjgDblxLsbById(String sjrq)
    {
        return reportDkjgDblxLsbMapper.selectReportDkjgDblxLsbById(sjrq);
    }

    /**
     * 查询贷款结构趋势-担保类型结构图4.3.1.1.1-3列表
     * 
     * @param reportDkjgDblxLsb 贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * @return 贷款结构趋势-担保类型结构图4.3.1.1.1-3
     */
    @Override
    public List<ReportDkjgDblxLsb> selectReportDkjgDblxLsbList(ReportDkjgDblxLsb reportDkjgDblxLsb)
    {
        return reportDkjgDblxLsbMapper.selectReportDkjgDblxLsbList(reportDkjgDblxLsb);
    }

    /**
     * 新增贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * 
     * @param reportDkjgDblxLsb 贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * @return 结果
     */
    @Override
    public int insertReportDkjgDblxLsb(ReportDkjgDblxLsb reportDkjgDblxLsb)
    {
        reportDkjgDblxLsb.setCreateTime(DateUtils.getNowDate());
        return reportDkjgDblxLsbMapper.insertReportDkjgDblxLsb(reportDkjgDblxLsb);
    }

    /**
     * 修改贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * 
     * @param reportDkjgDblxLsb 贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * @return 结果
     */
    @Override
    public int updateReportDkjgDblxLsb(ReportDkjgDblxLsb reportDkjgDblxLsb)
    {
        return reportDkjgDblxLsbMapper.updateReportDkjgDblxLsb(reportDkjgDblxLsb);
    }

    /**
     * 批量删除贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * 
     * @param sjrqs 需要删除的贷款结构趋势-担保类型结构图4.3.1.1.1-3ID
     * @return 结果
     */
    @Override
    public int deleteReportDkjgDblxLsbByIds(String[] sjrqs)
    {
        return reportDkjgDblxLsbMapper.deleteReportDkjgDblxLsbByIds(sjrqs);
    }

    /**
     * 删除贷款结构趋势-担保类型结构图4.3.1.1.1-3信息
     * 
     * @param sjrq 贷款结构趋势-担保类型结构图4.3.1.1.1-3ID
     * @return 结果
     */
    @Override
    public int deleteReportDkjgDblxLsbById(String sjrq)
    {
        return reportDkjgDblxLsbMapper.deleteReportDkjgDblxLsbById(sjrq);
    }

    /**
     * 贷款结构趋势-担保类型结构图4.3.1.1.1-3
     * @param reportDkjgDblxLsb
     * @param userInfo
     * @return
     */
    @Override
    public List<ReportDkjgDblxLsb> dblxjgt(ReportDkjgDblxLsb reportDkjgDblxLsb, LoginUser userInfo) {
        List<ReportDkjgDblxLsb> doList = new ArrayList<ReportDkjgDblxLsb>();

        /**
         * 判断数据日期是否为近3年4个季度以及当年每个月月末
         */
        ArrayList<String> sjrqs = DateUtilss.getThreeYearFourQuarterAndMonth();
        if (!StringUtils.isEmpty(reportDkjgDblxLsb.getSjrq())) {
            if ("9999".equals(reportDkjgDblxLsb.getSjrq())) {
                reportDkjgDblxLsb.setSjrq("");
            }
            sjrqs = new ArrayList<String>();
            String sjrq = reportDkjgDblxLsb.getSjrq();
            sjrq = sjrq.replace("-", "");
            sjrqs.add(sjrq);
        }
        reportDkjgDblxLsb.setSjrqs(sjrqs);

        doList = reportDkjgDblxLsbMapper.dblxjgt(reportDkjgDblxLsb);

        return doList;
    }
}
